/// *
// * Copyright (c) 2018, ZeeSec Technologies. All rights reserved.
// * ZeeSec PROPRIETARY/CONFIDENTIAL.
// */
//
// package zeepos.mongo;
//
// import java.util.List;
//
// import org.bson.Document;
// import org.bson.json.JsonWriterSettings;
// import org.springframework.data.mongodb.core.MongoTemplate;
// import org.springframework.data.mongodb.core.convert.MongoConverter;
//
// import com.alibaba.fastjson.JSONObject;
// import com.mongodb.MongoClient;
// import com.mongodb.client.MongoCursor;
// import com.zeesec.nsm.common.domain.object.IPGroup;
// import com.zeesec.nsm.common.domain.object.IPItem;
//
/// **
// * @author ZhiQiang Chen
// * @date 2018-11-25 22:16:31
// */
//
// public class TestUpdate {
// @SuppressWarnings("resource")
// public static void main(String[] args) {
// MongoClient mongoClient = new MongoClient("127.0.0.1", 27111);
// MongoTemplate mongo = new MongoTemplate(mongoClient, "zeerule");
// // User user = new User();
// // user.setUuid("123");
// // user.setName("aa");
// // user.setPas("bb");
// // mongo.save(user, "USER");
// // Criteria criteria = Criteria.where("uuid").is("123");
// // Update update = new Update();
// // update.set("name", "cc");
// // Query query = new Query(criteria);
// // User one = mongo.findOne(query, User.class, "USER");
// // System.out.println(one);
// // one.setName("dd");
// // mongo.save(one, "USER");
// MongoConverter converter = mongo.getConverter();
// MongoCursor<Document> mongoCursor =
/// mongo.getCollection("IP_GROUP").find().iterator();
// while (mongoCursor.hasNext()) {
// Document document = mongoCursor.next();
// JsonWriterSettings settings = JsonWriterSettings.builder()
// .int64Converter((value, writer) ->
/// writer.writeNumber(value.toString())).build();
// String json = document.toJson(settings);
// IPGroup ipGroup = JSONObject.parseObject(json, IPGroup.class);
// IPGroup read = converter.read(IPGroup.class, document);
// System.out.println(ipGroup);
// }
// List<IPGroup> list = mongo.findAll(IPGroup.class);
// for (IPGroup ipGroup : list) {
// List<IPItem> includeItems = ipGroup.getIncludeItems();
// for (IPItem ipItem : includeItems) {
// System.out.println(ipItem.getIp4Range().getStartAsString());
// }
// }
// }
// }
